package StringBuffer;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class Exercise {
    public static void main(String[] args) {
        String str = null;
        StringBuffer s1 = new StringBuffer();
        //当传入空时，底层调用的是父类的appendNull方法，将null字符串赋给s1
        s1.append(str);
        System.out.println(s1.length());
        System.out.println(s1);

        //此时底层会走super(str.length + 16)因为str为空，所以会报空指针异常
        StringBuffer s2 = new StringBuffer(str);
        System.out.println(s2);

    }
}
